<{extends file="$tpl_dir/tpl_base.htm"}>
<{block name="main"}>
<div class="main-head">
  <div class="main-head_title">
    <h2>学校</h2>
  </div>
</div>
<div class="main-body">
  <div class="main-action">
  	<a href="<{$url.base}>/create" class="mod-btn mod-btn_primary">新增</a>
	<a href="javascript:;" data-action="delete" class="mod-btn j-action">删除</a>
	<div class="main-search">
      <form method="get">
        <input type="text" name="keyword" class="mod-inpt" placeholder="学校名称关键字" value="<{$gets.keyword}>">
        <input type="submit" class="mod-btn mod-btn_primary" value="搜索">
      </form>
    </div>
  </div>
  <div class="mod-box">
    <table class="mod-table">
      <thead>
        <tr>
          <th class="col-chkbox"><label class="mod-chkbox">
            <input type="checkbox" data-action="chkall">
            </label></th>
          <th>ID</th>
          <th>学校名称</th>
		  <th>排序</th>
		  <th>管理员</th>
          <th class="col-operate">操作</th>
        </tr>
      </thead>
      <tbody>
      <{foreach $list as $row}>
      <tr>
        <td class="col-chkbox"><label class="mod-chkbox">
          <input type="checkbox" name="chkid[]" value="<{$row.id}>">
          </label></td>
        <td><{$row.id}></td>
        <td><{$row.title}></td>
		<td><{$row.displayorder}></td>
		<td><{$row.admin}></td>
        <td class="col-operate"><a href="<{$url.base}>/edit?id=<{$row.id}>">编辑</a> <a href="javascript:;" class="bind_admin">绑定管理员</a></td>
      </tr>
      <{/foreach}>
      </tbody>
    </table>
	<{if !$list}>
    <div class="mod-nothing">暂无信息</div>
    <{/if}>
  </div>
  <{if $list}>
  <div class="pagination"><{$show_page}></div>
  <{/if}> </div>
<{/block}>
<{block name="foot" append}>
<script type="text/javascript">
(function(){
	$(".bind_admin").on("click", function(){
		var f, id = $(this).closest("tr").find("input").val();
		JUtil.dialog({
			title: "绑定管理员",
			content: '<div class="mod-tips">1个管理员只能绑定1个学校，以最后一次提交为准。</div>\
				<form method="post" autocomplete="off"><div class="mod-form">\
							<div class="mod-form_item">\
								<div class="mod-form_label required">管理员用户名</div>\
								<div class="mod-form_input">\
								   <input type="text" name="username" class="mod-inpt mod-width_short">\
								</div>\
							</div>\
						  </div> </form>',
			load: function(){
				f = JUtil.submit(this.$bd.find("form"), {
					action: window._URL_.base + "/bind_admin",
					input: {
						username: {
							ch: "管理员用户名"
						}
					},
					extdata: {
						actid: id
					},
					success: function(res){
						window.location.reload();
						return false
					}
				});
			},
			buttons: [
				{
					onClick: function(){
						return f.$form.submit(), false
					}
				}		  
			]
		});
	});
})();
</script>
<{/block}>